package com.mt.course.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.mt.common.PagerInfo;
import com.mt.common.ServiceResult;
import com.mt.common.constants.BaseErrorConstants;
import com.mt.course.api.service.IExaminationWrongFeedbackService;
import com.mt.course.entity.ExaminationWrongFeedbackEntity;
import com.mt.course.service.model.ExaminationWrongFeedbackServiceModel;

@Service
public class ExaminationWrongFeedbackServiceImpl implements IExaminationWrongFeedbackService {

    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ExaminationWrongFeedbackServiceImpl.class);

    @Autowired
    private ExaminationWrongFeedbackServiceModel examinationWrongFeedbackServiceModel;

    public ServiceResult<ExaminationWrongFeedbackEntity> findInfo(Map<String, Object> params) {
        ServiceResult<ExaminationWrongFeedbackEntity> result = null;
        // 该参数标识前段是否需要权限数据
        try {
            result = examinationWrongFeedbackServiceModel.selectInfo(params);
        } catch (Exception e) {
            LOGGER.error("[ExaminationWrongFeedbackServiceImpl][findInfo]：query findInfo occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询详情错误");
        }
        return result;
    }

    public ServiceResult<List<ExaminationWrongFeedbackEntity>> findList(Map<String, Object> params,
        PagerInfo<?> pagerInfo) {
        ServiceResult<List<ExaminationWrongFeedbackEntity>> result =
            new ServiceResult<List<ExaminationWrongFeedbackEntity>>();
        try {
            result = examinationWrongFeedbackServiceModel.selectList(params, pagerInfo);
        } catch (Exception e) {
            LOGGER.error("[ExaminationWrongFeedbackServiceImpl][findList]：query findList occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询列表错误");
        }

        return result;
    }

    public ServiceResult<Integer> doInsert(ExaminationWrongFeedbackEntity examinationWrongFeedbackEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = examinationWrongFeedbackServiceModel.insert(examinationWrongFeedbackEntity);
        } catch (Exception e) {
            LOGGER.error("[ExaminationWrongFeedbackServiceImpl][doInsert]：query doInsert occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "创建信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doDeleteById(Integer examinationWrongFeedbackId) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = examinationWrongFeedbackServiceModel.deleteByPrimaryKey(examinationWrongFeedbackId);
        } catch (Exception e) {
            LOGGER.error("[ExaminationWrongFeedbackServiceImpl][doDeleteById]：query doDeleteById occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "删除信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doUpdate(ExaminationWrongFeedbackEntity examinationWrongFeedbackEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = examinationWrongFeedbackServiceModel.updateByPrimaryKeySelective(examinationWrongFeedbackEntity);
        } catch (Exception e) {
            LOGGER.error("[ExaminationWrongFeedbackServiceImpl][doUpdate]：query doUpdate occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "更新信息错误.");
        }
        return result;
    }

}
